<include file='Index/header' />
<div class="row">
	<br>
	<div class="col-sm-12">
		<table id="feedback_table" class="table table-hover table-bordered table-striped table-striped">
			<thead>
				<tr>
					<td>编号</td>
					<td>提交人</td>
          <td>手机</td>
					<td>提交时间</td>
					<td>处理人</td>
					<td>状态</td>
					<td>反馈内容</td>
					<td>处理内容</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</div>
	<br>
</div>
<include file='Index/footer' />
<script>
$(document).ready(function() {
		loadTable();
});
var table;
function loadTable(){
	table = $('#feedback_table').DataTable({
		"bProcessing": true,
		"bDestroy": true,
		"sPaginationType" : "input",
		"oLanguage" : {
              "sLengthMenu": "每页显示 _MENU_ 条记录",
              "sZeroRecords": "抱歉， 没有找到",
              "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
              "sInfoEmpty": "没有数据",
              "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
              "sZeroRecords": "没有检索到数据",
               "sSearch": "搜索: &nbsp",
              "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "前一页",
                "sNext": "后一页",
                "sLast": "尾页"
              }
          }, 
		"ajax":'{:U("Admin/Homepage/getFeedback/")}',
		"columns": [
					{ "data": 'id' },
					{ "data": 'user' },
          { "data": 'user' },
	        { "data": 'createtime' },
	        { "data": 'admin' },
	        { "data": 'status' },
	        { "data": 'feedback_content' },
	        { "data": 'deal_content' },
	        { "data": 'btn' }
    ],
    "columnDefs": [
    {
    	"targets": 0,
    	"render": function (data, type, row, table) {
        return table.row + 1;
      }
    },
    {
    	"targets": 1,
    	"render": function (data, type, row, table) {
        return data == null? '':transNull(data.name);
      }
    },
    {
      "targets": 2,
      "render": function (data, type, row, table) {
        return transNull(data.phone);
      }
    },
    {
    	"targets": 4,
    	"render": function (data, type, row, table) {
        return data == null? '':transNull(data.name);
      }
    },
    {
    	"targets": 5,
    	"render": function (data, type, row, table) {
        return data == '0'? '未处理':'已处理';
      }
    },
    {
    	"targets": -1,
    	"data": null,
    	"render": function (data, type, row, table) {
    		if(row.status == '0'){
    			return '<button class="btn btn-info" onclick="deal(\''+row.feedback_id+'\')">处理</button>';
    		}else{
    			return null;
    		}
      },
    }]
	});
}

function deal(feedback_id){
	$('#feedback_id').attr('value', feedback_id);
	$('#feedback_modal').modal('show');
}

function submit(){
	$('#feedback_form').ajaxSubmit({
      success:function(data){
        $('#feedback_modal').modal('hide');
        location.reload();
      }
  });
}
</script>
<div id="feedback_modal" class="modal fade">
  <div class="modal-dialog" >
    <div class="modal-content">
    	<div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
          <h4 class="modal-title">用户反馈</h4>
      </div>
      <div class="modal-body">
				<div class="row">
					<form id="feedback_form" action='{:U("Admin/Homepage/updateFeedback")}' method="post">
					<div class="form-group">
						<div class="col-sm-12">
							<div class="col-sm-1"></div>
							<div class="col-sm-3" style="padding-left:15px;padding-top:5px">
								<label for="deal_content" class="control-label">处理内容：</label>
							</div>
							<div class="col-sm-6">
								<input id="feedback_id" name="feedback_id" class="form-group" style="display:none" />
								<input id="status" name="status" class="form-group" style="display:none" value="1" />
								<textarea id="deal_content" name="deal_content" class="form-control" style="height:100px"></textarea>
							</div>
						</div>
					</div>
					</form>
				</div>
			</div>
			<div class="modal-footer">
        <button class="btn btn-primary" onclick="submit()">保存</button>
        <button class="btn btn-defalt" data-dismiss="modal">取消</button>
    	</div>
		</div>
	</div>
</div>